﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="cn_collect.aspx.cs" Inherits="He.Web.manage.collect.cn_collect" %>

<%@ Register Src="../_uc/head.ascx" TagPrefix="uc" TagName="head" %>
<%@ Import Namespace="He.Common" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>采集进程</title>
    <uc:head runat="server" ID="uchead" />
    <style type="text/css">
        .msg
        {
            color: Red;
            font-weight: bold;
        }
    </style>
    <script type="text/javascript">
        $(function () {
            $(".msg").html("<img src=\"../images/loading.gif\" />正在准备采集……");
            var url_list = "<%=collect_list %>";
            var url_arr = new Array();
            url_arr = url_list.split(",");
            var successnum = 0;
            var failnum = 0;
            for (var i in url_arr) {
                $.ajax({
                    type: "post",
                    url: "../../tools/collect_ajax.ashx",
                    dataType: "json",
                    data: "url=" + url_arr[i] + "&category_id=<%=category_id %>&random=" + Math.random(),
                    success: function (data) {
                        $(".msgtable").append("<tr><td>" + data.msgbox + "</td></tr>");
                        //采集失败
                        if (data.msg == "0") {
                            failnum = failnum + 1;
                            $(".msg").html("<img src=\"../images/loading.gif\" />采集进度：共执行" + url_arr.length + "个任务，成功" + successnum + "个，" + "失败" + failnum + "个。");
                        }
                        //采集成功
                        else {
                            successnum = successnum + 1;
                            $(".msg").html("<img src=\"../images/loading.gif\" />采集进度：共执行" + url_arr.length + "个任务，成功" + successnum + "个，" + "失败" + failnum + "个。");
                        }
                        //任务结束
                        if (failnum + successnum == url_arr.length) {
                            $(".msg").html("采集结束：共执行" + url_arr.length + "个任务，成功" + successnum + "个，" + "失败" + failnum + "个。");
                        }
                    },
                    error: function (data, status, e) {
                        $(".msgtable").append("<tr><td> <font color='red'>× 错误：" + e + "</font>  </td></tr>");
                        failnum = failnum + 1;
                        $(".msg").html("<img src=\"../images/loading.gif\" />采集进度：共执行" + url_arr.length + "个任务，成功" + successnum + "个，" + "失败" + failnum + "个。");
                        //任务结束
                        if (failnum + successnum == url_arr.length) {
                            $(".msg").html("采集结束：共执行" + url_arr.length + "个任务，成功" + successnum + "个，" + "失败" + failnum + "个。");
                        }
                    }
                });
            }
        })  
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div class="navigation">
        <span class="back"><a href='javascript:(history.go(-1))'>返回列表</a></span> <b>您当前的位置：首页
            &gt; 采集管理&gt;采集进程</b>
    </div>
    <div class="spClear">
    </div>
    <table width="100%" border="0" cellspacing="0" cellpadding="0" class="msgtable">
        <tr>
            <td class="msg">
                <img src="../images/loading.gif" />正在准备，请稍等……
            </td>
        </tr>
    </table>
    </form>
</body>
</html>
